const mongoose = require('mongoose')
const { Schema, model } = mongoose

// 文档schema
const commentSchema = new Schema({
    __v: {
        type: Number,
        select: false
    },
    content: {
        type: String,
        required: true
    },
    // 关注者
    commentator: {
        type: Schema.Types.ObjectId,
        ref: 'User',
        required: true,
        select: false
    },
    // 问题id
    questionId: {
        type: String,
        required: true,
    },
    // 回答id
    answerId: {
        type: String,
        required: true,
    },
    // 根评论的id
    rootCommentId: {
        type: String,
    },
    // 向谁回复这个信息
    replyTo: {
        type: Schema.Types.ObjectId,
        ref: 'User',
    }
}, { timestamps: true })

module.exports = model('Comment', commentSchema)